Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unsubscribe functionality at backend (#236) #237

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

prakkhar03
Copy link

@prakkhar03 prakkhar03 commented Nov 27, 2024

Closes #236

Summary
Added unsubscribe functionality to the backend to allow users to opt out of subscription services.

Changes

Implemented UnsubscribeAPIView to handle user unsubscribe requests.
Added a new endpoint for unsubscribe in the urls.py.
Updated the Subscriber model and serializer for supporting unsubscribe.
Improved responses and error handling for both subscription and unsubscribe flows.

Type of change

  • Bug fix
  • Feature update
  • Breaking change
  • Documentation update

Flags

Ensure the unsubscribe logic doesn't conflict with existing subscription logic.
Review if email validation works correctly during unsubscribe.

Demo

How has this been tested?

Endpoint for unsubscribe: /api/unsubscribe/

{
"email": "[email protected]"
}

Response

{
"message": "You have successfully unsubscribed. We're sad to see you go!"
}

###Author Checklist

  • Code has been commented, particularly in hard-to-understand areas
  • Changes generate no new warnings
  • Vital changes have been captured in unit and/or integration tests
  • New and existing unit tests pass locally with my changes
  • Documentation has been extended, if necessary
  • Merging to main from fork: djangoindia.orgtest

How Tested

Manually tested the unsubscribe API endpoint with valid and invalid email addresses.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Django India! 🎉🇮🇳

We're so happy to see you contribute. Your efforts mean a lot to us and we're excited to have you on this journey.

Before we proceed, please take a moment to review our contribution guide. It's packed with all the information you need to make your contribution seamless.

If you're fixing an issue from the Django India issue tracker, remember to get it assigned to you before you acutally start working on it.

If you ever need help or just want to chat, the Django India discord server is always open. We're here for you!

And while you're here, don't forget to ⭐ star our repo to show your support! It helps the community grow.

Thank you for being a part of Django India. Together, let's make an amazing community! 🚀

ankanchanda
ankanchanda previously approved these changes Nov 29, 2024
@DevilsAutumn
Copy link
Member

DevilsAutumn commented Nov 29, 2024

Looks good 👍
We also need to add an unsubscribe link in the template we use for sending the updates, so that anyone can unsubscribe from mail itself.
A little research will be required to understand how are we going to send the email of the user in the body to unsubscribe endpoint from the mail.

Can you please have a look? @prakkhar03

@prakkhar03
Copy link
Author

Ya Sure I'll look into it

Copy link
Member

@DevilsAutumn DevilsAutumn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @prakkhar03 ! Left few minor comments, Rest looks good.
There might be some changes depending upon #235 , so lets wait for that to get merged.

class UnsubscribeAPIView(generics.GenericAPIView):
def delete(self, request, token=None):
try:
unsubscribe_token = token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prakkhar03, we should avoid using try-except unless there’s code where we’re uncertain about how it might fail. Also you can use token directly to check condition no need to store at another variable

@DevilsAutumn
Copy link
Member

Need to rebase this to main.

@ankanchanda
Copy link
Collaborator

let's merge this soon. no point on extending.

@prakkhar03
Copy link
Author

@ankanchanda I will make a few changes today and commit them. Once done, the branch will be ready for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] To allow users to unsubscribe from updates
4 participants